Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

data-menu: remove/deprecate old data menu #3281

Merged
merged 11 commits into from
Jan 7, 2025

Conversation

kecnry
Copy link
Member

@kecnry kecnry commented Nov 12, 2024

Description

This pull request removes the old data-menu and exposes the new data-menu. This keeps the old icon/button, but only shows a tooltip pointing to the new data-menu. Old API access is deprecated and points to alternatives in the new data menu API.

Change log entry

  • Is a change log needed? If yes, is it added to CHANGES.rst? If you want to avoid merge conflicts,
    list the proposed change log here for review and add to CHANGES.rst before merge. If no, maintainer
    should add a no-changelog-entry-needed label.

Checklist for package maintainer(s)

This checklist is meant to remind the package maintainer(s) who will review this pull request of some common things to look for. This list is not exhaustive.

  • Are two approvals required? Branch protection rule does not check for the second approval. If a second approval is not necessary, please apply the trivial label.
  • Do the proposed changes actually accomplish desired goals? Also manually run the affected example notebooks, if necessary.
  • Do the proposed changes follow the STScI Style Guides?
  • Are tests added/updated as required? If so, do they follow the STScI Style Guides?
  • Are docs added/updated as required? If so, do they follow the STScI Style Guides?
  • Did the CI pass? If not, are the failures related?
  • Is a milestone set? Set this to bugfix milestone if this is a bug fix and needs to be released ASAP; otherwise, set this to the next major release milestone. Bugfix milestone also needs an accompanying backport label.
  • After merge, any internal documentations need updating (e.g., JIRA, Innerspace)?

@kecnry kecnry added this to the 4.1 milestone Nov 12, 2024
@github-actions github-actions bot added documentation Explanation of code and concepts cubeviz specviz embed Regarding issues with front-end embedding imviz plugin Label for plugins common to multiple configurations labels Nov 12, 2024
@kecnry kecnry force-pushed the dm-remove-old branch 4 times, most recently from 44a42dc to 40df2dd Compare November 18, 2024 19:56
@kecnry kecnry force-pushed the dm-remove-old branch 2 times, most recently from ae9a458 to 2afd53e Compare December 2, 2024 14:53
@kecnry kecnry force-pushed the dm-remove-old branch 2 times, most recently from dccca7e to 6dda0d5 Compare December 6, 2024 20:45
@kecnry kecnry force-pushed the dm-remove-old branch 2 times, most recently from 3bbcebd to d5bd148 Compare December 20, 2024 21:07
@rosteen rosteen modified the milestones: 4.1, 4.2 Dec 23, 2024
@kecnry kecnry force-pushed the dm-remove-old branch 5 times, most recently from aa009c1 to 7e6d924 Compare January 2, 2025 20:00
@kecnry kecnry marked this pull request as ready for review January 3, 2025 13:45
Comment on lines -105 to -116
@pytest.mark.skip(reason="filenames changed")
@pytest.mark.remote_data
@pytest.mark.filterwarnings(r"ignore::astropy.wcs.wcs.FITSFixedWarning")
@pytest.mark.parametrize(
"uri, expected_helper", example_uri_helper
)
def test_auto_config_detection(uri, expected_helper):
url = f'https://mast.stsci.edu/api/v0.1/Download/file/?uri={uri}'
fn = download_file(url, timeout=100)
helper_name, hdul = identify_helper(fn)
hdul.close()
assert helper_name == expected_helper
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved to test_config_detection.py

Comment on lines -30 to -102
def test_data_menu_toggles(specviz_helper, spectrum1d):
# load 2 data entries
specviz_helper.load_data(spectrum1d, data_label="test")
app = specviz_helper.app
sv = app.get_viewer('spectrum-viewer')
new_spec = specviz_helper.get_spectra(apply_slider_redshift=True)["test"]*0.9
specviz_helper.load_data(new_spec, data_label="test2")

# check that both are enabled in the data menu
selected_data_items = app._viewer_item_by_id('specviz-0')['selected_data_items']
data_ids = list(selected_data_items.keys())
assert len(data_ids) == 2
assert np.all([visible == 'visible' for visible in selected_data_items.values()])
assert len(sv.layers) == 2
assert np.all([layer.visible for layer in sv.layers])

# disable (hide layer) for second entry
app.set_data_visibility('specviz-0', app._get_data_item_by_id(data_ids[-1])['name'],
visible=False)

selected_data_items = app._viewer_item_by_id('specviz-0')['selected_data_items']
assert selected_data_items[data_ids[0]] == 'visible'
assert sv.layers[0].visible is True
assert selected_data_items[data_ids[1]] == 'hidden'
assert sv.layers[1].visible is False

# add a subset and make sure it appears for the first data entry but not the second
specviz_helper.plugins['Subset Tools'].import_region(
SpectralRegion(6000 * spectrum1d.spectral_axis.unit, 6500 * spectrum1d.spectral_axis.unit))

assert len(sv.layers) == 4
assert sv.layers[2].visible is True # subset corresponding to first (visible) data entry
assert sv.layers[3].visible is False # subset corresponding to second (hidden) data entry

# enable data layer from menu and subset should also become visible
app.set_data_visibility('specviz-0', app._get_data_item_by_id(data_ids[-1])['name'],
visible=True)
assert np.all([layer.visible for layer in sv.layers])

# manually hide just the data layer, and the visiblity state in the menu should show as mixed
sv.layers[3].visible = False

selected_data_items = app._viewer_item_by_id('specviz-0')['selected_data_items']
assert selected_data_items[data_ids[0]] == 'visible'
assert selected_data_items[data_ids[1]] == 'mixed'


def test_visibility_toggle(imviz_helper):
arr = np.arange(4).reshape((2, 2))
imviz_helper.load_data(arr, data_label='no_results_data')
app = imviz_helper.app
iv = app.get_viewer('imviz-0')

# regression test for https://github.com/spacetelescope/jdaviz/issues/1723
# test to make sure plot options (including percentile) stick when toggling visibility
# via the data menu checkboxes
selected_data_items = app._viewer_item_by_id('imviz-0')['selected_data_items']
data_ids = list(selected_data_items.keys())
assert selected_data_items[data_ids[0]] == 'visible'
assert iv.layers[0].visible is True
po = imviz_helper.plugins['Plot Options']
po.stretch_preset = 90
assert po.stretch_preset.value == 90

app.set_data_visibility('imviz-0', app._get_data_item_by_id(data_ids[0])['name'],
visible=False)

assert iv.layers[0].visible is False

app.set_data_visibility('imviz-0', app._get_data_item_by_id(data_ids[0])['name'],
visible=True)
assert iv.layers[0].visible is True
assert po.stretch_preset.value == 90
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reimplemented in configs/default/tests/test_data_menu.py

Copy link
Contributor

@pllim pllim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like the fact that this PR removes more code than it adds. I don't grok all the internals. A quick usability test using Imviz example notebook seems to work fine. Left some general comments. Thanks!

Where is the toggle for single selection on click vs multiselect on click on the new data dropdown? Looks like the latter is the default now. So when I have multiple subset and I want to edit only one of them (in fact, the "edit subset" option is only enabled when one subset is selected), I have to click at least 2x to get to that feature. Was this by design or is there more follow-up work on this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the ones I reasonably could. @camipacifici - do you still have the source (with annotations) to update this one? I suppose this probably isn't urgent until the deprecation period is over, but I agree is definitely something we should update at some point.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I probably do. I'll take a look next week.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I wait for this to reach a resolution (one way or another) before I approve?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@camipacifici said she would do this is a follow-up next week - so only if you think this needs to block merge (but I personally don't think its urgent since the button is still there for the next two releases).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah now that it opens up the new stuff, I am less worried.

@data-item-remove="$emit('data-item-remove', $event)"
@change-reference-data="$emit('change-reference-data', $event)"
></j-viewer-data-select>
<j-tooltip tooltipcontent="data-menu is now opened by clicking on the legend in the top-right of the viewer">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible when people click this anyway, it opens up the data menu at the new location (in addition to this tooltip)? Took me a second to understand what "legend in the top-right of viewer" really mean. I suspect it will be confusing to others as well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was my original plan, but the way the two are implemented entirely differently (and the way the anchors are done) makes it difficult. If anyone thinks this is worth (significantly) more effort, I can give it another shot.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... What about popping up a screenshot or putting a link in the tooltip to point to a screenshot of the new location? If not, it is okay.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

managed to figure out a way to open the data menu (with the caveat that it will open all instances if there are multiple instances of the app visible)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@pllim
Copy link
Contributor

pllim commented Jan 3, 2025

p.s. Maybe a different ticket but by now, the fancy videos (https://jdaviz--3281.org.readthedocs.build/en/3281/video_tutorials.html) and GIFs are pretty outdated now. That is especially obvious with this change because data dropdown is fundamental to Jdaviz usage.

@kecnry
Copy link
Member Author

kecnry commented Jan 4, 2025

Where is the toggle for single selection on click vs multiselect on click on the new data dropdown? Looks like the latter is the default now. So when I have multiple subset and I want to edit only one of them (in fact, the "edit subset" option is only enabled when one subset is selected), I have to click at least 2x to get to that feature. Was this by design or is there more follow-up work on this?

The previous menu's single vs multiselect was for the visibilities (there was no analog for selecting to modify). But either way, this follows (afaik) the current design plan pending user feedback. There is technically an API switch for single vs multi select for the layer selection - we could for now implement the ability to use that mixed with the UI clicks and then it would just be a matter of adding a UI-toggle if we ever want it.

@kecnry
Copy link
Member Author

kecnry commented Jan 6, 2025

@pllim - the latest commit enables support for single-select mode if/when switched from the API (data_menu.layer.multiselect = False)

Copy link

codecov bot commented Jan 6, 2025

Codecov Report

Attention: Patch coverage is 82.92683% with 7 lines in your changes missing coverage. Please review.

Project coverage is 88.02%. Comparing base (3cb9540) to head (a18b8f0).
Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
...viz/configs/default/plugins/data_menu/data_menu.py 84.00% 4 Missing ⚠️
jdaviz/configs/default/plugins/viewers.py 62.50% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3281      +/-   ##
==========================================
- Coverage   88.13%   88.02%   -0.12%     
==========================================
  Files         127      127              
  Lines       19698    19717      +19     
==========================================
- Hits        17361    17355       -6     
- Misses       2337     2362      +25     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@gibsongreen gibsongreen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code changes look good, added/changed descriptions read through well, and remove and added functionality works great!

@kecnry kecnry merged commit 19ddfac into spacetelescope:main Jan 7, 2025
25 of 27 checks passed
@kecnry kecnry deleted the dm-remove-old branch January 7, 2025 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cubeviz documentation Explanation of code and concepts embed Regarding issues with front-end embedding imviz plugin Label for plugins common to multiple configurations Ready for final review specviz
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants